#include <iostream>
#include <string>

using namespace std;

class Operation{
protected:
    double numA = 0;
    double numB = 0;
    
public:
    void setNumA(double val){
        numA = val;
    }
    void setNumB(double val){
        numB = val;
    }
    virtual double getResult(){
        double res = 0;
        return res;
    }
};

class OperationAdd : public Operation{
    double getResult(){
        return numA + numB;
    }
};

class OperationMul : public Operation{
    double getResult(){
        return numA * numB;
    }
};

class OperationFactory{
public:
    static Operation* creatOperation(char op){
        Operation* oper = nullptr;
        switch(op){
            case '+':
                oper = new OperationAdd;
            break;
                
            case '*':
                oper = new OperationMul;
            break;
            
            default:
            return nullptr;                
        }
        
        return oper;
    }
};


int main(void){
    Operation* oper = OperationFactory::creatOperation('*');
    if(oper == nullptr) return 0;
    oper->setNumA(10);
    oper->setNumB(20);
    double res = oper->getResult();
    cout << "res: " << res << endl;
    return 0;
}
